package com.woniuxy.hrp.web.AdminController;

import com.woniuxy.hrp.entity.Patient;
import com.woniuxy.hrp.service.PatientService;
import com.woniuxy.hrp.unityhandler.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: hrph
 * @InterfaceName PatientController
 * @description:患者账号锁定Controller
 * @author: WY
 **/
@Transactional
@RestController("adminpatientcontroller")
@RequestMapping("/api/v1/admin/patient")
public class PatientController {

    @Autowired
    private PatientService patientService;

    //查询所有患者账号
    @GetMapping("/list")
    public ResponseEntity findAll(){
        List<Patient> patients = patientService.getAll();
        return new ResponseEntity("200","OK",patients);
    }

    //患者账号锁定(冻结)
    @PostMapping("/update")
    public ResponseEntity lock(int id){
        patientService.lock(id);
        return new ResponseEntity("200","OK",null);
    }

    @PostMapping("/unlock")
    //患者账号解冻
    public ResponseEntity unlock(int id){
        patientService.unlock(id);
        return new ResponseEntity("200","OK",null);
    }
}
